package 笔试.京东.第一题;

import java.util.LinkedList;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

//        int n = sc.nextInt();
        int n=4;
        LinkedList<Integer> list = new LinkedList<>();

        int[] arr = new int[]{2, 3, 5};
        if (n == 0)
            System.out.println(0);
        if (n == 1)
            System.out.println(2);
        if (n == 2)
            System.out.println(3);
        if (n == 3)
            System.out.println(5);
        int res = 0;
        list.offer(2);
        list.offer(3);
        list.offer(5);
        int size=3;
        while (!list.isEmpty())
        {
            int temp = list.pop();

            for (int i = 0; i < arr.length; i++)
            {
                int pp = temp * 10 + arr[i];
                list.offer(pp);
                size++;
            }
            if (size == n)
            {
                res = list.peekLast();
                break;
            }
            else if (size>n)
            {
                int c=size-n;
                for (int i = 0; i < c+1; i++)
                {
                    res=list.pollLast();
                }
                break;
            }
        }
        System.out.println(res);
    }
}
